import { apiClient } from './axios';

// 车辆管理相关接口
export const vehiclesApi = {
  // 获取车辆列表
  getVehicles: (params?: {
    page?: number;
    per_page?: number;
    search?: string;
    vehicle_type?: string;
    status?: string;
    area_id?: number;
  }) => {
    return apiClient.get('/vehicles', { params });
  },

  // 获取单个车辆详情
  getVehicle: (vehicleId: number) => {
    return apiClient.get(`/vehicles/${vehicleId}`);
  },

  // 创建车辆
  createVehicle: (vehicleData: {
    license_plate: string;
    vehicle_type: string;
    brand?: string;
    model?: string;
    year?: number;
    color?: string;
    status?: string;
    area_id?: number;
    driver_id?: number;
    notes?: string;
  }) => {
    return apiClient.post('/vehicles', vehicleData);
  },

  // 更新车辆
  updateVehicle: (vehicleId: number, vehicleData: {
    license_plate?: string;
    vehicle_type?: string;
    brand?: string;
    model?: string;
    year?: number;
    color?: string;
    status?: string;
    area_id?: number;
    driver_id?: number;
    notes?: string;
  }) => {
    return apiClient.put(`/vehicles/${vehicleId}`, vehicleData);
  },

  // 删除车辆
  deleteVehicle: (vehicleId: number) => {
    return apiClient.delete(`/vehicles/${vehicleId}`);
  },

  // 获取车辆选项列表（用于下拉选择）
  getVehicleOptions: (params?: { status?: string; area_id?: number }) => {
    return apiClient.get('/vehicles/options', { params });
  },

  // 更新车辆状态
  updateVehicleStatus: (vehicleId: number, status: string) => {
    return apiClient.put(`/vehicles/${vehicleId}/status`, { status });
  }
};